#include "loadchart.h"

LoadChart::LoadChart(QCustomPlot* _customPlot) : BaseChart(_customPlot)
{
    initChart();
}

void LoadChart::initChart()
{
    //添加图形
    customPlot->addGraph();
    customPlot->addGraph();

    //设置X轴坐标范围
    customPlot->xAxis->setRange(0,100);
    //设置Y轴坐标范围
    customPlot->yAxis->setRange(-1100,1100);

    //设置画笔
    customPlot->graph(0)->setPen(QPen(Qt::red));

    customPlot->graph(0)->setName("负荷位移曲线");
    customPlot->graph(1)->setName("负荷位移曲线");

    //设置X轴文字标注
    customPlot->xAxis->setLabel("时间(ms)");
    //设置Y轴文字标注
    customPlot->yAxis->setLabel("负荷(N)");

//    customPlot->graph(0)->setBrush(QBrush(QColor(255,255,0)));
    customPlot->graph(0)->setBrush(QBrush(QColor(255,255,255)));



    QVector<double> temp(20);
    QVector<double> temp1(20);
    //图形为y = 100*x;
    for(int i=0;i<20;i++)
    {
        temp[i] = i;
        temp1[i] = 10*i+10;
    }

    customPlot->graph(0)->setData(temp, temp1);

    //重绘 每次改变完以后都要调用这个进行重新绘制
    customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);

}

void LoadChart::setLoadData(QSharedPointer<QVector<float> > _pLoad)
{
    this->pLoad = _pLoad;
}
